﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Globalization;
using Wix.Aura.Common.CustomTypes;

namespace Wix.Aura.Common {
    public class Product : IXmlSerializable {
		public Product(Guid id, Language language, string manufacturer, string name, string version, Package package) {
			Id = id;
			Language = language;
			Manufacturer = manufacturer;
			Name = name;
			Version = version;
			Package = package;
			AppId = new List<AppId>();
			Binary = new List<BinaryFile>();
			ComplianceCheck = new List<ComplianceCheck>();
			Component = new List<Component>();
		}

		public Guid Id { get; set; }
		public Language Language { get; set; }
		public string Manufacturer { get; set; }
		public string Name { get; set; }
		public string Version { get; set; }
		public int? CodePage { get; set; }
		public Guid? UpgradeCode { get; set; }
		public Package Package { get; set; }
		public ICollection<AppId> AppId { get; private set; }
		public ICollection<BinaryFile> Binary { get; private set; }
		public ICollection<ComplianceCheck> ComplianceCheck { get; private set; }
		public ICollection<Component> Component { get; private set; }

		public System.Xml.Schema.XmlSchema GetSchema() {
			throw new NotImplementedException();
		}

		public void ReadXml(System.Xml.XmlReader reader) {
			throw new NotImplementedException();
		}

		public void WriteXml(System.Xml.XmlWriter writer) {
			writer.WriteStartElement("Product");
			writer.WriteAttribute("Id", Id);
			writer.WriteAttribute("Language", Language);
			writer.WriteAttribute("Manufacturer", Manufacturer);
			writer.WriteAttribute("Name", Name);
			writer.WriteAttribute("Version", Version);
			writer.WriteAttribute("Codepage", CodePage);
			writer.WriteAttribute("UpgradeCode", UpgradeCode);
			Package.WriteXml(writer);
			writer.WriteElements(AppId);
			writer.WriteElements(Binary);
			writer.WriteElements(ComplianceCheck);
			writer.WriteElements(Component);
			writer.WriteEndElement();
		}
	}
}
